<template>
  <div class="page">
    <div class="title">客户认定服务等级申请</div>
    <div class="searchContent">
      <div class="inputContent">
        <ui-form class="query-form" :model="queryForm" label-width="120px">
          <ui-form-item label="客户类型">
            <ui-select placeholder="请选择客户类型" v-model="queryForm.customType" @change="getCustomLevel">
              <ui-option v-for="(item, index) in customTypeList" :key="index" :value="item.id" :label="item.name"></ui-option>
            </ui-select>
          </ui-form-item>
          <ui-form-item label="管理类型">
            <ui-select placeholder="请选择管理类型" v-model="queryForm.manageType">
              <ui-option v-for="(item, index) in manageTypeList" :key="index" :value="item.id" :label="item.name"></ui-option>
            </ui-select>
          </ui-form-item>
          <ui-form-item label="客户等级">
            <ui-select placeholder="请选择客户等级" v-model="queryForm.customLevel" :disabled="queryForm.customType == 1">
              <ui-option v-for="(item, index) in customLevelList" :key="index" :value="item.id" :label="item.name"></ui-option>
            </ui-select>
          </ui-form-item>
          <ui-form-item label="客户姓名">
            <ui-input type="text" placeholder="请输入客户名称" v-model="queryForm.customName"> </ui-input>
          </ui-form-item>
          <ui-form-item label="联系电话">
            <ui-input type="text" placeholder="请输入联系电话" v-model="queryForm.phone"> </ui-input>
          </ui-form-item>
          <ui-form-item label="证件号码">
            <ui-input type="text" placeholder="请输入证件号码" v-model="queryForm.idNumber"> </ui-input>
          </ui-form-item>
        </ui-form>
      </div>
      <div class="searchButton">
        <ui-button class="default-btn reset" @click="reset">重置</ui-button>
        <ui-button class="primary-btn" @click="search">查询</ui-button>
      </div>
    </div>
    <div class="tableContent">
      <div class="name">客户列表</div>
      <vx-nodata :list="tableData" v-loading="isLoading" sub-title="暂无数据">
        <vx-table :tableData="tableData" :columns="columns" :customer-style="true">
          <template slot="operation" slot-scope="scope">
            <ui-button type="text" @click="editCustomLevel(scope)">修改客户等级</ui-button>
            <ui-button type="text" @click="showEditHistory(scope)">历史修改记录</ui-button>
          </template>
        </vx-table>
        <ui-pagination
          :total="total"
          :page-size="pageSize"
          :current-page="currentPage"
          :layout="layout"
          :page-sizes="pageSizeList"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
        >
        </ui-pagination>
      </vx-nodata>
    </div>

    <ui-dialog title="历史修改记录" :visible.sync="editHistoryVisible" width="65%">
      <div class="table">
        <vx-table :tableData="historyTableData" :columns="historyColumns" :buttomGroup="buttomGroup"> </vx-table>
        <ui-pagination
          :total="total"
          :page-size="pageSize"
          :current-page="currentPage"
          :layout="layout"
          :page-sizes="pageSizeList"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
        >
        </ui-pagination>
      </div>
      <span slot="footer" class="dialog-footer">
        <ui-button @click="editHistoryVisible = false">取 消</ui-button>
        <ui-button type="primary" @click="editHistoryVisible = false">确 定</ui-button>
      </span>
    </ui-dialog>
  </div>
</template>

<script>
import pagination from '@/common/mixin/pagination.js'; // 混入/分页
import vxTable from '@/components/vx-table';
export default {
  name: 'myCustom',
  mixins: [pagination],
  components: {
    vxTable,
  },
  data() {
    return {
      queryForm: {},
      customTypeList: [
        { id: 1, name: '全部' },
        { id: 2, name: '类型一' },
        { id: 3, name: '类型二' },
      ],
      manageTypeList: [
        { id: 1, name: '类型一' },
        { id: 2, name: '类型二' },
      ],
      customLevelList: [
        { id: 1, name: '类型一' },
        { id: 2, name: '类型二' },
      ],
      setRelationList: [
        { id: 1, name: '类型一' },
        { id: 2, name: '类型二' },
      ],
      isConcernList: [
        { id: 1, name: '是' },
        { id: 2, name: '否' },
      ],
      tableData: [
        { customName: '1111111111', isConcern: 0 },
        { customName: '1111111111', isConcern: 0 },
        { customName: '1111111111', isConcern: 1 },
      ],
      columns: [
        {
          label: '序号',
          prop: 'index',
          formatter: (row, column, cellValue, index) => {
            return index + 1;
          },
        },
        {
          label: '客户名称',
          prop: 'customName',
        },
        {
          label: '客户类型',
          prop: 'customType',
        },
        {
          label: '管护机构',
          prop: 'householdManagementInstitution',
        },
        {
          label: '金融资产',
          prop: 'financialAssets',
        },
        {
          label: '客户等级',
          prop: 'financialAssets',
          formatter: (row, column, cellValue, index) => {
            return row.customLevel;
          },
        },
      ],
      customSelection: [],
      isLoading: false,
      editHistoryVisible: false,
      buttomGroup: [],
      historyTableData: [
        { customName: '1111111111', isConcern: 0 },
        { customName: '1111111111', isConcern: 0 },
      ],
      historyColumns: [
        {
          label: '客户号',
          prop: 'customType',
          width: 120,
        },
        {
          label: '客户名称',
          prop: 'customName',
          width: 120,
        },
        {
          label: '客户类型',
          prop: 'customType',
          width: 120,
        },
        {
          label: '当前等级',
          prop: 'customType',
          width: 120,
        },
        {
          label: '变更等级',
          prop: 'customType',
          width: 120,
        },
        {
          label: '有效期至',
          prop: 'customType',
          width: 120,
        },
        {
          label: '申请理由',
          prop: 'customType',
          width: 120,
        },
        {
          label: '变更时间',
          prop: 'customType',
          width: 120,
        },
      ],
    };
  },
  mounted() {
    this.searchList();
  },
  methods: {
    searchList() {},
    getCustomLevel(e) {},
    search() {
      this.pageNum = 1;
      this.searchList();
    },
    reset() {
      this.queryForm.customName = undefined;
      this.queryForm.manageType = undefined;
      this.queryForm.customLevel = undefined;
      this.queryForm.customType = undefined;
      this.queryForm.idNumber = undefined;
      this.queryForm.phone = undefined;
      this.searchList();
    },
    editCustomLevel(row) {
      this.$router.push({
        path: '/customManager/customServeLevelApply/editCustomLevel',
        query: {
          customInfo: row,
        },
      });
    },
    showEditHistory(row) {
      this.editHistoryVisible = true;
    },
  },
};
</script>

<style lang="scss" scoped>
.page {
  .title {
    font-size: 18px;
    color: #000;
    font-weight: bold;
  }
  .searchContent {
    background: #fff;
    padding: 20px 20px 0 20px;
    margin-top: 10px;
    .inputContent {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      padding: 10px;
      ::v-deep .ui-input {
        width: 190px !important;
      }
      ::v-deep .query-form .ui-form-item {
        width: 23% !important;
      }
    }
    .searchButton {
      padding: 10px 10px 10px 10px;
      display: flex;
      justify-content: right;
      align-items: center;
      .reset {
        border-color: #5085f9;
        color: #5085f9;
      }
    }
  }
  .tableContent {
    margin-top: 20px;
    background: #fff;
    padding: 20px;
    .name {
      font-size: 14px;
      color: #000;
      margin-bottom: 20px;
      font-weight: bold;
    }
    .concern {
      background: #fff;
      border-color: orange;
      color: orange;
      font-size: 14px;
    }
    .alreayConcern {
      background: #fff;
      border-color: #ccc;
      font-size: 14px;
    }
  }
}
.table {
  margin-top: 30px;
}
.query-form {
  display: flex;
  flex-wrap: wrap;
}
</style>
